{{include file ="admin/header.tpl"}}{{include file
="admin/navibar.tpl"}} {{include file ="admin/sidebar.tpl"}}

<script type="text/javascript"
	src="{{$smarty.const.WEBSITE_URL}}public/assets/lib/ajaxupload.js"></script>

<script type="text/javascript">
  var weburl = '{{$smarty.const.WEBSITE_URL}}';
  getUsermassage();


	//文件上传组件处理
	jQuery(function () {
		 	var button = jQuery('#selectfile');//绑定事件
		var load = new AjaxUpload(button, { //绑定AjaxUpload
	    action: "{{$smarty.const.WEBSITE_URL}}admin/fileupload/fileup",//文件要上传到的处理页面,语言可以PHP,ASP,JSP等
	    type:"POST",//提交方式
	    data:{ //还可以提交的值
	        module:"ajaxupload",
	        type:jQuery("#__mstype__").attr("value")
	    },
	    autoSubmit:true,//选择文件后,是否自动提交.这里可以变成true,自己去看看效果吧.
	    name:'msUploadFile',//提交的名字
	    onChange:function(file,ext){ //当选择文件后执行的方法,ext存在文件后续,可以在这里判断文件格式
// 			$("#user_image").attr("value",file);
	    },
	    onSubmit: function (file, ext) { //提交文件时执行的方法
	    	if(ext && /^(jpg|jpeg|png|gif)$/.test(ext)){
				//ext是后缀名
	    		button.value = "正在上传…";
	    		button.disabled = "disabled";
			}else{	
				alert("不支持的文件格式！只能上传jpg|jpeg|png|gif") ;
				return false;
			}
	    },
	    onComplete: function (file, response) { //文件提交完成后可执行的方法
	        button.text('浏览');
	        this.enable();
			var data=eval("("+response+")");
			if(data.type==0){
				alert(data.message);
			}else{
				$('#user_image').val(data.filename);
				$("#user_img").attr("src","{{$smarty.const.WEBSITE_URL}}upload/"+data.filename);
	        	
			}
	    }
	});
	});
	
  
function getUsermassage(){
	$.ajax({
        type: "POST",
        url: weburl+'admin/adminusermanage/getMsg',
        success:function(data){
        	var udata =   JSON.parse(data);
        	console.log(udata,'%');
        	$("#id").val(udata.id);
        	$("#user_name").val(udata.user_name);
        	$("#mobile").val(udata.mobile);
        	$("#email").val(udata.email);
        	$("#user_image").val(udata.user_image);
        	$("#passwd").val(udata.passwd);

        	$("#user_img").attr("src","{{$smarty.const.WEBSITE_URL}}upload/"+udata.user_image);
        	
	    },
        error: function () {
        }
    });
}
function modify(){
	$.ajax({
		type:"post",
        url: weburl+'admin/adminusermanage/modify',
        data:$('#loadform').serialize(),
        success:function(data){
            if(data >0){
                alert("修改成功!");
            }
	    },
        error: function () {
        }
    });
}

function changePhoto(){
	
}
</script>
<div class="content">
	<div class="header">
		<div class="stats">
			<p class="stat">
				<!--span class="number"></span-->
			</p>
		</div>

		<h1 class="page-title">管理员个人信息管理</h1>
	</div>

	<!-- <ul class="breadcrumb">
            <li><a href="{{$smarty.const.WEBSITE_URL}}admin/user">管理列表</a> <span class="divider">/</span></li>  
			 <a title= "移除快捷菜单" ><li class="active"><i class="icon-minus" method="del" url="#"></i></li></a>
	         <a title= "加入快捷菜单" ><li class="active"><i class="icon-plus" method="add" url="#"></i></li></a>
        </ul> -->
	<div class="container-fluid">
		<div class="row-fluid">
            <br/><br/><br/>

		
			<form id="loadform" method="post" class="form-horizontal"
				style="width: 200px">

				<div class="control-group" hidden="true">
					<input type="text" id="user_image" name="user_image" hidden="true" />
					<input type="text" id="id" name="id" hidden="true" />
				</div>
				<div class="control-group">
					<label class="control-label" for="Text input">用户名:</label>
					<div class="controls">
						<input id="user_name" placeholder="用户名" name="user_name"> </input>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="Text input">联系号码:</label>
					<div class="controls">
						<input id="mobile" placeholder="联系号码" name="mobile"> </input>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="Text input">邮箱:</label>
					<div class="controls">
						<input id="email" placeholder="邮箱" name="email"> </input>
					</div>
				</div>

				<div class="control-group">
					<label class="control-label" for="Text input">密码</label>
					<div class="controls">
						<input id="passwd" type="password" placeholder="密码" name="passwd"> </input>
					</div>
				</div>

				<div class="control-group">
					<label class="control-label" for="Text input">个人头像:</label>
					<div class="controls">
						<input type="button" class="btn btn-small"
							id="selectfile" value="图片选择" />
					</div>
				</div>
                <div class="control-group" >
                    <label class="control-label" for="Text input">预览头像:</label>
                    <div class="controls">
                    <img id="user_img" alt=""
                         src="{{$smarty.const.WEBSITE_URL}}public/photo/3.jpg" width="100px"
                         height="100px" class="img-polaroid" />
                    </div>
                </div>
				<div class="control-group" align="right">
					<button type="button" class="btn btn-primary" onclick="modify()">修改</button>
				</div>
			</form>

		</div>
	</div>
	<!--- END 以下内容不需更改，请保证该TPL页内的标签匹配即可 --->
	{{include file="admin/footer.tpl" }}